/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package unc.pds.facets;

import unc.pds.auth.IPDSSecurity;
import unc.pds.filemodel.FolderRemote;
import unc.pds.model.Postable;
import unc.pds.model.UserRemote;

/**
 *
 * @author Mikhail
 */
public class FoldersFacet implements Facet {
    public FoldersFacet(Postable user, IPDSSecurity security) {
        this.user = user;
        this.security = security;
    }
    private Postable user;
    private IPDSSecurity security;
    public String draw() throws Exception {
        String result = "";
        FolderRemote[] folders = user.getFolders();
        for (int i = 0; i < folders.length; i++) {
            result += "<p><a href=\"index.jsp?id="+folders[i].getKey()+"\">"+folders[i].getName()+"</a>";
            if (security.getPermission(folders[i].getKey(), "delete")) {
                result += " <a href=\"filesystem-processor.jsp?objid="+folders[i].getKey()+"&action=delete\"><img src=\"img/delete.png\" alt=\"Удалить\"/></a>";
            }
            result += "</p>\n";
        }
        return result;
    }
    public boolean isSide() {
        return false;
    }
}
